]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/system: Indicate "battery health" status
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 17 Sep 2024 17:36:55 +0000 (19:36 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 29 Aug 2025 21:13:07 +0000 (23:13 +0200)
"Preserve battery health" is a new feature which limits battery
charging in order to increase battery longevity.

Currently when the charging limit is hit, the state is
indistinguishable from the unplugged, discharging state,
which isn't great: The user has no way to know whether
the limit was reached, or they accidentally unplugged
the device.

To address this, use dedicated icons in the plugged-in-
but-not-charging case.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5228
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3474>

data/dbus-interfaces/org.freedesktop.UPower.Device.xml
js/ui/status/system.js

index 488228505bbcbcbb9f8a44515101880177e7182f..503a62ebb3e03a845d64b7b0d179394a4c976c07 100644 (file)
@@ -7,5 +7,6 @@
     <property name="TimeToFull" type="x" access="read"/>
     <property name="IsPresent" type="b" access="read"/>
     <property name="IconName" type="s" access="read"/>
+    <property name="ChargeThresholdEnabled" type="b" access="read"/>
   </interface>
 </node>
index baebf21ef6225136d0b4df72e2fc956323be066f..a98d2e6584b54ef68fddcb402434cf1c5ae84092 100644 (file)
@@ -74,8 +74,15 @@ const PowerToggle = GObject.registerClass({
             return;
 
         // The icons
-        let chargingState = this._proxy.State === UPower.DeviceState.CHARGING
-            ? '-charging' : '';
+        let chargingState;
+        if (this._proxy.State === UPower.DeviceState.CHARGING)
+            chargingState = '-charging';
+        else if (this._proxy.State === UPower.DeviceState.PENDING_CHARGE &&
+                 this._proxy.ChargeThresholdEnabled)
+            chargingState = '-plugged-in';
+        else
+            chargingState = '';
+
         let fillLevel = 10 * Math.floor(this._proxy.Percentage / 10);
         const charged =
             this._proxy.State === UPower.DeviceState.FULLY_CHARGED ||